<template>
	<view>
		<z-nav-bar title="比赛计分"></z-nav-bar>
		<view class="bg">
			<view class="add" @click="add">
				<image :src="`${setting.sImgUrl}/add.png`"></image>
				新建比赛
			</view>
		</view>
		<view class="entry">
			<view class="title">历史比赛</view>
			<view v-if="info.length">
				<navigator class="row" v-for="(v, k) in info" :key="k" hover-class="none" :url="'/pages/student/play/detail?id=' + v.id">
					<view class="text">
						<view class="left">
							洞球
							<text></text>
						</view>
						：
						<view>{{ v.hole }}</view>
					</view>
					<view class="text">
						<view class="left">
							时间
							<text></text>
						</view>
						：
						<view>{{ v.createTime }}</view>
					</view>
					<view class="text">
						<view class="left">
							比赛人数
							<text></text>
						</view>
						：
						<view>{{ v.num }}人</view>
					</view>
				</navigator>
			</view>
			<z-no-data v-else placeholder="暂无历史记录"></z-no-data>
		</view>
	</view>
</template>

<script>
import { historyPlay } from '@/api/student';
export default {
	data() {
		return {
			info: []
		};
	},
	methods: {
		getInfo() {
			historyPlay().then((res) => {
				this.info = res.rows;
			});
		},
		add() {
			uni.removeStorageSync('playData')
			uni.navigateTo({
				url: '/pages/student/play/save'
			})
		}
	},
	onShow() {
		// #ifdef MP-WEIXIN
		this.nav = uni.getMenuButtonBoundingClientRect().height;
		// #endif
	},
	onLoad() {
		this.getInfo();
	}
};
</script>

<style scoped>
@import './css/play.css';
</style>
